using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Routing;
using DotNetNuke.Web.Api;

namespace DynamicGeneration.Modules.WebApiExplorer
{
    public class WebApiController : DnnApiController
    {
        [HttpGet]
        [AllowAnonymous]
        public HttpResponseMessage GetRichRouteData()
        {
            List<Route> routes = new List<Route>();
            foreach (RouteBase item in RouteTable.Routes)
            {
                Route route = item as Route;
                if (route != null)
                    routes.Add(route);
            }

            var data = from route in routes
                       select new RouteGraph(route);

            return base.Request.CreateResponse(HttpStatusCode.OK, data);
        }

        [HttpPost]
        [DnnAuthorize]
        public HttpResponseMessage Echo(SampleInfo info)
        {
            return Request.CreateResponse(HttpStatusCode.OK, info);
        }

    }
}
